<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//登录
Route::post('login',[\App\Http\Controllers\Admin\LoginController::class,'login']);

Route::group(['middleware' => 'auth:admin'],function (){
    Route::post('logout', [\App\Http\Controllers\Admin\LoginController::class, 'logout']);
    Route::apiResource('update/user',\App\Http\Controllers\Admin\AdminController::class);
    Route::apiResource('checkbook',\App\Http\Controllers\Admin\CheckBookController::class);

});



//数据库
Route::get('data',[\App\Http\Controllers\DataController::class,'index']);

//请求和依赖注入
Route::get('user/{id}/{uid}',[\App\Http\Controllers\UserController::class,'index']);

//测试获取表单提交的值
Route::get('view',[\App\Http\Controllers\UserController::class,'view']);

//生成URL
Route::get('url/{id}',[\App\Http\Controllers\UserController::class,'url']);

//生成命名路由的url
Route::any('url/{ids}',[\App\Http\Controllers\UserController::class,'url'])->name('url.ids');

//测试中间件
Route::get('admin',[\App\Http\Controllers\LoginController::class,'index'])->middleware('check');

